package DesignPattern.SimpleFactory;



import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * @author idealist

 */
public class OperatorFactory {
        static Map<String, Operation> operatorMap=new HashMap<>();
        static {
            operatorMap.put("add",new Addition());
            operatorMap.put("divide",new Division());
            operatorMap.put("multiply",new Multiplication());
            operatorMap.put("subtract",new Subtraction());
        }
        public static Optional<Operation> getOperation(String operator){
            return Optional.ofNullable(operatorMap.get(operator));
        }

    }
